package demo;

/**
 * 最大子序列和
 */
class Solution8 {
	public int maxSubArray(int[] nums) {
		int sum = 0;
		for (int num : nums) {
			if (num > 0) {
				sum += num;
			} else {
				sum = num;
			}
			sum = sum > 0 ? sum : 0;
		}
		return sum;
	}
}

